package com.hc.music.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hc.music.common.R;
import com.hc.music.dao.ManagerMapper;
import com.hc.music.entity.Manager;
import com.hc.music.service.ManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;

@Service
public class ManagerServiceImpl extends ServiceImpl<ManagerMapper,Manager> implements ManagerService {
    @Autowired
    private ManagerMapper managerMapper;

    @Override
    public R verifyPassword(Manager manager, HttpSession session) {
        QueryWrapper<Manager> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("name",manager.getName());
        queryWrapper.eq("password",manager.getPassword());
        if(managerMapper.selectCount(queryWrapper) > 0){
            session.setAttribute("name",manager.getName());
            return R.success("登录成功");
        }else {
            return R.error("用户名或密码错误");
        }
    }
}
